package com.zxc.flowSum;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FlowSumMap extends Mapper<LongWritable, Text, Text, FlowSum> {
    Text k = new Text();
    FlowSum v = new FlowSum();

    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, FlowSum>.Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] fields = line.split("\t");
        k.set(fields[0]);
        long up = Long.parseLong(fields[fields.length - 3]);
        long down = Long.parseLong(fields[fields.length - 2]);
        v.setAll(up, down);
        context.write(k,v);
    }

}
